﻿#include "stdafx.h"
#include "CLIState.h"

using namespace System;
namespace $RootNamespace$
{

	void $Context$::Test()
	{
		// Setup context in a $IState$ 
		$Context$ ^c = gcnew $Context$(gcnew $ConcreteStateA$());
	
		// Client requests, that changes $RootNamespace$ 
		c->Request();
		c->Request();
		c->Request();
	
	}

	$Context$::$Context$($IState$ ^p$IState$)
	{
		this->CurrentState = p$IState$;
	}

	void $Context$::Request()
	{
		Console::WriteLine("Request on " + CurrentState->ThisState);
		CurrentState->$Handle$(this);
	}

	void $ConcreteStateA$::$Handle$($Context$ ^context)
	{
		context->CurrentState = gcnew $ConcreteStateB$();
	}

	System::String ^$ConcreteStateA$::ThisState::get()
	{
		return "$ConcreteStateA$";
	}

	void $ConcreteStateB$::$Handle$($Context$ ^context)
	{
		context->CurrentState = gcnew $ConcreteStateC$();
	}

	System::String ^$ConcreteStateB$::ThisState::get()
	{
		return "$ConcreteStateB$" ;
	}

	void $ConcreteStateC$::$Handle$($Context$ ^context)
	{
		context->CurrentState = gcnew $ConcreteStateA$();
	}

	System::String ^$ConcreteStateC$::ThisState::get()
	{
		return "$ConcreteStateC$" ;
	}
}